package com.test.controller;

import com.test.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * @Author：徐志荣
 * @Date：2023/6/7 下午 7:43
 */
@Controller
public class StudentController3 {

    //方法3:构造方法注入
//    private StudentService studentService;
    private  final  StudentService studentService;

    @Autowired
    public StudentController3(StudentService studentService) {
        this.studentService = studentService;
    }

    public void sayHi(){
        //调用service方法
        studentService.sayHi();
    }
}
